<?php
/**
 * Created by PhpStorm.
 * User: Lin
 * Date: 2017/3/18 0018
 * Time: 上午 11:05
 */
Class StoreAction extends CommonAction {
    public function showList(){
        $store=M("store")->select();
        $this->store=$store;
        $this->display();
    }

    public function addStore(){
        $this->display();
    }

    public function editStore(){
        $id=$_GET['id'];
        $this->store=M('store')->find($id);
        $this->display('addStore');
    }

    public function deleteStore(){
        $id=$_GET['id'];
        if(M('store')->delete($id)){
            $this->success('删除成功');
        }else{
            $this->error('删除失败');
        }
    }

    //运行保存
    public function runSave(){
        $add=$_GET['add'];
        $payment=$_POST;
        if($add){
            $result=M('store')->add($payment);
        }else{
            $result=M('store')->save($payment);
        }
        $val=$add?'添加':'编辑';
        if($result){
            $this->success($val.'成功',U(GROUP_NAME.'/Store/showList'));
        }else{
            $this->error($val.'失败');
        }
    }
}